package com.ljxt.dt.vo;

import java.util.List;

/**
 * @author 唐春劲
 * @version 1.0.0
 * @date 2020-05-05 20:57
 * @copyright 老九学堂
 */

public class PageVO<T> {

    /**
     * 当前页数
     */
    private  Integer pageIndex;
    /**
     * 每页显示的数据条数
     */
    private  Integer pageSize;
    /**
     * 当前页的显示数据
     */
    private List<T> data;
    /**
     * 如果是通过查询得到的则将查询的对象保存进去
     */
    private T selectObj;
    /**
     * 分页中点击后请求的URL地址
     */
    private String pageURL;
    /**
     * 总页数
     */
    private  Integer pages;
    /**
     * 该查询数据的总条数
     */
    private  Integer total;

    public PageVO(List<T> data,Integer pageIndex,Integer pageSize,Integer total) {
        this.data = data;
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
        this.total = total;
        this.pages = (int) Math.ceil ((double)total / pageSize);
    }

    public Integer getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(Integer pageIndex) {
        this.pageIndex = pageIndex;
    }

    public Integer getPageSize() {
        return pageSize;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public T getSelectObj() {
        return selectObj;
    }

    public void setSelectObj(T selectObj) {
        this.selectObj = selectObj;
    }

    public String getPageURL() {
        return pageURL;
    }

    public void setPageURL(String pageURL) {
        this.pageURL = pageURL;
    }

    public Integer getPages() {
        return pages;
    }

    public void setPages(Integer pages) {
        this.pages = pages;
    }

    public Integer getTotal() {
        return total;
    }

    public void setTotal(Integer total) {
        this.total = total;
    }

    @Override
    public String toString() {
        return "PageVO{" +
                "pageIndex=" + pageIndex +
                ", pageSize=" + pageSize +
                ", data=" + data +
                ", selectObj=" + selectObj +
                ", pageURL='" + pageURL + '\'' +
                ", pages=" + pages +
                ", total=" + total +
                '}';
    }
}
